import request from './request'
import type {
  IgnoreRule,
  InsertIgnoreRuleRequest,
  UpdateIgnoreRuleRequest,
  DeleteIgnoreRuleRequest,
  ApiResponse,
  QueryAccountInfoResponse,
} from '@/types/ignoreRule'

const API_BASE = '/v1/cmdb-blacklist/ignore'

// 获取所有忽略规则
export const getAllIgnoreRules = (): Promise<QueryAccountInfoResponse> => {
  return request.get(API_BASE)
}

// 添加忽略规则
export const insertIgnoreRule = (
  data: InsertIgnoreRuleRequest
): Promise<ApiResponse> => {
  return request.post(API_BASE, data)
}

// 更新忽略规则
export const updateIgnoreRule = (
  data: UpdateIgnoreRuleRequest
): Promise<ApiResponse> => {
  return request.put(API_BASE, data)
}

// 删除忽略规则
export const deleteIgnoreRule = (id: number): Promise<ApiResponse> => {
  return request.delete(API_BASE, {
    params: { id },
  })
}
